package com.sample.kokou;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import android.app.Activity;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {

	private TextView displayView = null;
	private TextView selectView = null;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		
		displayView = (TextView)findViewById(R.id.displayView);
		Calendar calendar = Calendar.getInstance();
		SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
		displayView.setText(
			"Launched at " + df.format(calendar.getTime())
		);
		
		selectView = (TextView)findViewById(R.id.selectView);
		this.registerForContextMenu(selectView);
  }

	@Override
	public void onCreateContextMenu(ContextMenu menu, View v,
			ContextMenuInfo menuInfo) {
		this.getMenuInflater().inflate(R.menu.tasks, menu);
	}

	@Override
	public boolean onContextItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.lift:
			Toast.makeText(this, "Lift", Toast.LENGTH_SHORT).show();
			break;
		case R.id.play:
			Toast.makeText(this, "Play", Toast.LENGTH_SHORT).show();
			break;
		case R.id.rails:
			Toast.makeText(this, "Rails", Toast.LENGTH_SHORT).show();
			break;
		default:
		}
		return super.onContextItemSelected(item);
	}
}